x86/hvm: add pkeys support for guest_walk_tables
authorHuaitong Han <huaitong.han@intel.com>
Wed, 24 Feb 2016 11:04:19 +0000 (12:04 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 24 Feb 2016 11:04:19 +0000 (12:04 +0100)
commitccbe3b14489118b2c056ae4a841d3d8636a0ed22
treed30c4843cfd7bfc8faa2d2c4530306819548cdad
parent3c7d1da274845309942e8b1680148d62773af4b6
x86/hvm: add pkeys support for guest_walk_tables

Protection keys define a new 4-bit protection key field(PKEY) in bits 62:59 of
leaf entries of the page tables.

PKRU register defines 32 bits, there are 16 domains and 2 attribute bits per
domain in pkru, for each i (0 = i = 15), PKRU[2i] is the access-disable bit for
protection key i (ADi); PKRU[2i+1] is the write-disable bit for protection key
i (WDi). PKEY is index to a defined domain.

A fault is considered as a PKU violation if all of the following conditions are
true:
1.CR4_PKE=1.
2.EFER_LMA=1.
3.Page is present with no reserved bit violations.
4.The access is not an instruction fetch.
5.The access is to a user page.
6.PKRU.AD=1
    or The access is a data write and PKRU.WD=1
                and either CR0.WP=1 or it is a user access.

Signed-off-by: Huaitong Han <huaitong.han@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
xen/arch/x86/mm/guest_walk.c
xen/arch/x86/mm/hap/guest_walk.c
xen/include/asm-x86/guest_pt.h
xen/include/asm-x86/hvm/hvm.h
xen/include/asm-x86/page.h
xen/include/asm-x86/processor.h
xen/include/asm-x86/x86_64/page.h